// 生成随机手机号
import {UserType} from '@/type/user'

export function generateRandomPhoneNumber(): string {
  const prefix = ['130', '131', '132', '133', '134', '135', '136', '137', '138', '139',
    '150', '151', '152', '153', '155', '156', '157', '158', '159',
    '180', '181', '182', '183', '184', '185', '186', '187', '188', '189'];
  const randomPrefix = prefix[Math.floor(Math.random() * prefix.length)];
  const randomSuffix = Math.random().toString().slice(2, 10);
  return randomPrefix + randomSuffix;
}

export const info = ():UserType| null => {
  const auth = sessionStorage.getItem("info")
  if (auth) {
    return JSON.parse(auth)
  }
  return null
}


export const getOrderValue = (label) => {
  const arr = [
    {
      label: '0',
      value: '未付款'
    },
    {
      label: '1',
      value: '已付款'
    },
    {
      label: '2',
      value: '已发货'
    },
    {
      label: '3',
      value: '已签收'
    },
    {
      label: '4',
      value: '确认收货'
    },
    // 下面的没有用到应该
    {
      label: '5',
      value: '退货中'
    },
    {
      label: '6',
      value: '已退货'
    },
    {
      label: '7',
      value: '确认退货'
    },
  ]


  return arr.filter(item => item.label === label)[0]
}
export type getOrderValueType = ReturnType<getOrderValueType>
